<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
	</head>
	<body>
		<div class="box"></div>
		
		<script type="text/html" id="tpl">
			<p>{{name}}</p>
			<p>{{age}}</p>
		</script>
		
		<script type="text/javascript">
			var oBox = document.getElementsByClassName('box')[0],
				tpl = document.getElementById('tpl').innerHTML
			function tplReplce(tpl, replceObject) {
				return tpl.replace(/{{(.*?)}}/g, (node, key) => {
					return replceObject[key];
				})
			}
			var res = tplReplce(tpl, {name: 'zhangsan', age: '18'})
			oBox.innerHTML = res
		</script>
	</body>
</html>